//package com.jsyl.qies.business.service.impl;
//
//import com.jsyl.qies.business.domain.QuestionBank;
//import com.jsyl.qies.business.domain.QuestionProject;
//import com.jsyl.qies.business.dto.QuestionBankDTO;
//import com.jsyl.qies.business.dto.QuestionBankListDTO;
//import com.jsyl.qies.business.mapper.QuestionBankMapper;
//import com.jsyl.qies.business.mapper.QuestionProjectMapper;
//import com.jsyl.qies.business.service.IQuestionBankService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//
///**
// * @author xiaoshu
// * @date 2020-11-09 15:19
// * @desc
// **/
//@Service
//public class QuestionBankServiceImpl implements IQuestionBankService {
//
//    @Autowired
//    private QuestionBankMapper questionBankMapper;
//    @Autowired
//    private QuestionProjectMapper questionProjectMapper;
//
//    @Override
//    public List<QuestionBank> findList(QuestionBankListDTO questionListDTO) {
//        return questionBankMapper.selectList(questionListDTO);
//    }
//
//    /**
//     * 更新/维护 题库
//     *
//     * @param questionListDTO
//     * @return
//     */
//    @Override
//    @Transactional
//    public Boolean update(QuestionBankListDTO questionListDTO) {
//        //根据题目模块+题目+题目分数 筛选出题目，全部设置为已删除。
//        questionBankMapper.updateQuestionBankDelete(questionListDTO.getEvaluateModuleType(), questionListDTO.getEvaluateQuestion(), questionListDTO.getEvaluateScore());
//        //更新/维护/插入
//        for (QuestionBankDTO questionBankDTO : questionListDTO.getQuestion()) {
//            if (questionBankDTO.getId() == null) {//题目未存在，则更新插入
//                //目前就让他报错。暂时默认为固定，后续版本做可配置
//                QuestionProject questionProject = questionProjectMapper.select(questionListDTO.getEvaluateModuleType(), questionListDTO.getEvaluateQuestion(), questionListDTO.getEvaluateScore());
//
//                QuestionBank questionBank = new QuestionBank();
//                questionBank.setProjectType(questionProject.getProjectType());
//                questionBank.setProjectSecondType(questionProject.getProjectSecondType());
//                questionBank.setEvaluateModuleType(questionListDTO.getEvaluateModuleType());
//                questionBank.setEvaluateQuestion(questionListDTO.getEvaluateQuestion());
//                questionBank.setEvaluateScore(questionListDTO.getEvaluateScore());
//                questionBank.setQuestionName(questionBankDTO.getQuestionName());
//                questionBank.setQuestionContent(questionBankDTO.getQuestionContent());
//                questionBank.setInputType(questionBankDTO.getInputType());
//                questionBank.setModifyDirection(questionBankDTO.getModifyDirection());
//                questionBank.setQuestionReviseContent(questionBankDTO.getQuestionReviseContent());
//                questionBank.setIsDelete(0);
//                questionBankMapper.insert(questionBank);
//            } else {//题目存在，则更新操作
//                QuestionBank questionBank = questionBankMapper.selectById(questionBankDTO.getId());
//                questionBank.setQuestionName(questionBankDTO.getQuestionName());
//                questionBank.setQuestionContent(questionBankDTO.getQuestionContent());
//                questionBank.setInputType(questionBankDTO.getInputType());
//                questionBank.setModifyDirection(questionBankDTO.getModifyDirection());
//                questionBank.setQuestionReviseContent(questionBankDTO.getQuestionReviseContent());
//                questionBank.setIsDelete(0);
//                questionBankMapper.update(questionBank);
//            }
//        }
//        return null;
//    }
//}
